package com.cme.commons.kvs;

//import alluxio.AlluxioURI;
//import alluxio.client.keyvalue.KeyValueStoreWriter;
//import alluxio.client.keyvalue.KeyValueSystem;
//import alluxio.exception.AlluxioException;

import java.nio.ByteBuffer;

import alluxio.AlluxioURI;
import alluxio.client.keyvalue.KeyValueStoreWriter;
import alluxio.client.keyvalue.KeyValueSystem;
import alluxio.exception.AlluxioException;

/**
 * Created by ocean on 21/12/2016.
 */
public class KeyValueWriter001 {
	public static void main(String[] args) throws Exception, AlluxioException {
		// 1.创建键值对系统实例
		KeyValueSystem kvs = KeyValueSystem.Factory.create();

		// 2.开启键值对writer
		KeyValueStoreWriter writer = kvs.createStore(new AlluxioURI("/alluxiotest/kvstore"));

		// 3.写入键值对,byte[]类型数据
		writer.put("100".getBytes(), "foo".getBytes());

		// 4.写入键值对,ByteBuffer类型数据
		writer.put(ByteBuffer.wrap("200".getBytes()), ByteBuffer.wrap("bar".getBytes()));

		// 5.关闭键值对writer
		writer.close();
	}
}
